﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace University.Workshop.Presenters.Users
{
    public class PresenterReadUser
    {
        IReadBasicUser viewReadBasic;
        Model.User newUser = new Model.User() { Person = new Model.Person() };
        IReadPrincipalView view;

        public PresenterReadUser(IReadPrincipalView View, Model.User user)
        {
            view = View;
            newUser = user;           
        }

        public void FirstTime()
        {
            view.CallFirstPage();
            ProcedureAfterCall();
        }

        public void GoBackPage()
        {
            viewReadBasic.GoBackPage();
        }

        public void GoNextPage()
        {
            viewReadBasic.GoNextPage();
        }

        public void GoStepOne()
        {
            newUser = view.ReadBasic.UserToRead;
            view.CallFirstPage();
            ProcedureAfterCall();
        }

        public void GoStepTwo()
        {
            newUser = view.ReadBasic.UserToRead;
            view.CallSecondPage();
            ProcedureAfterCall();
        }

        private void ProcedureAfterCall()
        {

            if (viewReadBasic != null)
                newUser = viewReadBasic.UserToRead;
            viewReadBasic = view.ReadBasic;
            viewReadBasic.UserToRead = newUser;
            viewReadBasic.Update();
        }
    }
}
